//
//  mainView.m
//  spotrs
//
//  Created by xu on 16/5/11.
//  Copyright © 2016年 TZ. All rights reserved.
//

#import "mainView.h"
#import "lunBoTableViewCell.h"
#import "fenLeiTableViewCell.h"
#import "huoDongTableViewCell.h"
@implementation mainView 

-(id)initWithFrame:(CGRect)frame
{
   self = [super initWithFrame:frame];
    if (self) {
        [self creatView:frame];
    }
    return self;
}
-(void)creatView:(CGRect)frame
{
    _mainTabel = [[UITableView alloc] initWithFrame:frame];
    [_mainTabel setBackgroundColor:[UIColor grayColor]];
    [_mainTabel setDelegate:self];
    [_mainTabel setDataSource:self];
    [_mainTabel setSeparatorStyle:UITableViewCellSeparatorStyleSingleLineEtched];
    [self addSubview:_mainTabel];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 0) {
        lunBoTableViewCell *cell = (lunBoTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"lunbo"];
        if (!cell) {
            cell = [[lunBoTableViewCell alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
            [cell setRestorationIdentifier:@"lunbo"];
        }
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else if(indexPath.row == 1)
    {
        fenLeiTableViewCell *cell = (fenLeiTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"fenlei"];
        if (!cell) {
            cell = [[fenLeiTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"fenlei"];
            
        }
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else if(indexPath.row == 2)
    {
        huoDongTableViewCell *cell = (huoDongTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"huodong"];
        if (!cell) {
            cell = [[huoDongTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"huodong"];
            
        }
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else if(indexPath.row == 3)
    {
        huoDongTableViewCell *cell = (huoDongTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"huodong"];
        if (!cell) {
            cell = [[huoDongTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"huodong"];
            
        }
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else
    {
        UITableViewCell *cell = [[UITableViewCell alloc] init];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 200;
    }
    else if (indexPath.row == 1)
    {
        return 100;
    }
    else if (indexPath.row == 2)
    {
        return 160;
    }
    else if (indexPath.row == 3)
    {
        return 160;
    }
    else
    {
        return 100;
    }
}
@end
